//package com.eagle.scali.usercenter.listener.rocketmq;
//
//
//import com.eagle.scali.usercenter.dao.bonus.BonusEventLogMapper;
//import com.eagle.scali.usercenter.domain.dto.messaging.UserAddBonusMsgDTO;
//import com.eagle.scali.usercenter.domain.entity.bonus.BonusEventLog;
//import com.eagle.scali.usercenter.domain.entity.user.User;
//import com.eagle.scali.usercenter.service.user.UserService;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
//import org.apache.rocketmq.spring.core.RocketMQListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.stream.annotation.StreamListener;
//import org.springframework.cloud.stream.messaging.Sink;
//import org.springframework.stereotype.Service;
//
//import java.util.Date;
//
///**
// * bonus-consumer-group可以随便定义
// * topic要和生产者的topic对应
// */
//@Service
//@RocketMQMessageListener(consumerGroup = "bonus-consumer-group", topic = "add-bouns")
//@RequiredArgsConstructor(onConstructor = @__(@Autowired))
//@Slf4j
//public class AddBonusListener implements RocketMQListener<UserAddBonusMsgDTO> {
//    private final UserService userService;
//	private final BonusEventLogMapper bonusEventLogMapper;
//
//
//	@Override
//	public void onMessage(UserAddBonusMsgDTO message) {
//		log.info("接收到消息..{}",message.toString());
//		User user = this.userService.findById(message.getUserId());
//		user.setBonus(message.getBonus()+user.getBonus());
//		this.userService.updateUserById(user);
//
//		this.bonusEventLogMapper.insert(BonusEventLog.builder()
//		.userId(message.getUserId())
//		.value(message.getBonus())
//		.event("CONTRIBUTE")
//		.createTime(new Date())
//		.description("投稿加积分..").build());
//
//		log.info("更新完成");
//	}
//}
